Skip to content

Conversation

ARES2525
Copy link

@ARES2525 ARES2525 commented Oct 5, 2025

  • I have read CONTRIBUTING.md.
  • This pull request is all my own work -- I have not plagiarized it.
  • All filenames are in PascalCase.
  • All functions and variable names follow Java naming conventions.
  • All new algorithms have a URL in their comments that points to Wikipedia or other similar explanations.
  • All new code is formatted with clang-format -i --style=file path/to/your/file.java

Pull Request Description

What does this PR do?
Adds implementations for the "Search a 2D Matrix" problem (both variations) commonly found on LeetCode (#74 and #240). These algorithms are added under src/main/java/com/thealgorithms/matrix to provide useful matrix search solutions.

Why is this needed?
The current matrix directory lacks solutions for these frequently asked interview problems. Adding them will help learners and contributors understand efficient ways to search in 2D matrices.

Changes made:

  • Implemented Search2DMatrix.java containing methods for both matrix search variations.
  • Code follows Java naming conventions and project formatting guidelines.
  • Added relevant LeetCode URLs and explanations in comments for educational purposes.

Related Issue:
Fixes #6622

- Added JUnit tests covering both variations of 2D matrix search.
- Tests validate correctness for typical inputs and edge cases.
- Helps increase code coverage and ensures algorithm correctness.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE REQUEST] : Add Search a 2D Matrix in src/main/java/com/thealgorithms/matrix.

1 participant